var count=0;
if(window.localStorage.getItem("count")){
	count=parseInt(window.localStorage.getItem("count"));
}
window.onload=function(){
	count++;
	countspan=document.getElementsByClassName("count")[0];
	countspan.innerHTML=count;
	
	window.localStorage.setItem("count",count);
	
	
	var tx=document.getElementById("tx");
	tx.onmouseover=function(){
		this.src="./images/1.JPG";
	};
	tx.onmouseout=function(){
		this.src="./images/soldier.jpg";
	};
	
	var imgs=document.getElementsByClassName("ig");
	var dots=document.getElementsByClassName("dot");
	

	var timer=window.setInterval(show,2000);
	var index=0;
		
	function show(){
		for(var i=0;i<imgs.length;i++){
			if(i==index){
				imgs[i].classList.add("cur");
				dots[i].classList.add("cur");
			}
			else{
				imgs[i].classList.remove("cur");
				dots[i].classList.remove("cur");
			}
		}		
		index++;
		if(index>=imgs.length){
			index=0;
		}
	}
	
	for(var j=0;j<dots.length;j++){
		dots[j].onmouseover=function(){
			window.clearInterval(timer);
			for(var k=0;k<dots.length;k++){
				if(dots[k]==this){
					dots[k].classList.add("cur");
					imgs[k].style.display="block";
				}
				else{
					dots[k].classList.remove("cur");
					imgs[k].style.display="none";
				}
			}
			
		};
		dots[j].onmouseout=function(){
			timer=window.setInterval(show,2000);
		};
	}
};